<!DOCTYPE html>
<%@page import="cn.school.service.Service2"%>
<%@page import="cn.school.service.Service"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="cn.school.entity.*,java.util.*,cn.school.service.*,java.text.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改学生信息</title>
<style type="text/css">
form{
	border:1px solid black
}
</style>
<script type="text/javascript" src="js/jquery-3.2.0.js"></script>
</head>
<body>
	<%@include file="newcheckLogin.jsp"%>
	<%
		int stuno = Integer.parseInt(request.getParameter("stuno"));
		Service service = new Service();
		Student s = service.getOne(stuno);	
		if(s==null){
			out.print("<script>alert('学生不存在');history.back();</script>");
			return;
		}
	%>
	<form action="updateStuto.jsp?" method="post" enctype="multipart/form-data">
	<p><label>学号:</label>
			<input type="text" name="stuno" required="required"
				value="<%=s.getStuno()%>" />
		</p>
		<p><label>姓名:</label>
			<input type="text" name="sname" required="required"
				value="<%=s.getSname()%>" />
		</p>
		<p><label>性别:</label>	
		 <input type="radio" required name="sex" value="男"   />男
	 <input type="radio" required name="sex" value="女"   />女
	 <input type="radio" required name="sex" value="妖"   />	妖
	
	<%-- 男：<input type="radio" required name="sex" value="男" <%=s.getSex().equals("男")?"checked":""%> />
	女：<input type="radio" required name="sex" value="女" <%=s.getSex().equals("女")?"checked":""%>  />
	妖：<input type="radio" required name="sex" value="妖" <%=s.getSex().equals("妖")?"checked":"" %> />	 --%>
		</p>
		<p><label>电话:</label>
			<input type="text" name="telephone" value="<%=s.getTelephone()%>"/>
		</p>
		<p><label>qq:</label>
			<input type="text" name="qq" value="<%=s.getQq()%>"/>
		</p>
		<p><label>微信:</label>
			<input type="text" name="wechat" value="<%=s.getWechat()%>"/>
		</p>

		<p>
			<label>年级:</label>
			<%
			Service2 g = new Service2();
				List<Grade> list2 = g.findALL();
			%>
			<select name="gradeid">
				<%
					for (Grade gr : list2) {
				%>			
				<option value="<%=gr.getId()%>" <%-- <%
				if(gr.getId()==s.getGradeid()){
					out.print("selected='selected'");
				} %>--%>
				><%=gr.getGname()%></option>
				
				<%
					}
				%>
			</select>
			

		</p>
		 <p><label>入学日期:</label>
			<input type="text" name="enterdate" value="<%
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		 			if(s.getEnterdate()!=null){
		 				out.print(sdf.format(s.getEnterdate()));
		 			}
			%>"/>
		</p>  
		<p><label>来自哪个城市:</label>
			<input type="text" name="fromcity" value="<%=s.getFromcity()%>"/>
		</p>
 		<p><label>生日:</label>
 		
			<input type="text" name="birthday" value="<%
					SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
					if(s.getBirthday()!=null)
						//out.print(s.getBirthday());
					    out.print(sdf1.format(s.getBirthday()));
			
			%>"/>
		</p> 
		<p><label>地址:</label>
			<input type="text" name="address" value="<%=s.getAddress()%>"/>
		</p>
		<p><label>密码:</label>
			<input type="text" name="pass" value="<%=s.getPass()%>"/>
		</p>
		<p><label>照片:</label>
			<input type="file" name="idcardpic" value="<%=s.getIdcardpic()%>"/>
		</p>
		<p>
			<button type="submit" class="page-btn" name="save">确认</button>
		</p>
	</form>

</body>
<script>
 $(function(){
	  $(":radio[name=sex][value='<%=s.getSex()%>']").prop("checked",true);
	  $("select[name=gradeid]").val('<%=s.getGradeid()%>');
 });
</script>
</html>